﻿#ifndef LDRS_LOG_BROWSER_H
#define LDRS_LOG_BROWSER_H

#include <QMainWindow>
#include <QMutex>
#include <QMutexLocker>
#include "ZFCommonHeader.h"

class QTextBrowser;
class QToolBar;
class QAction;
class QLabel;

/**
 * @brief The ZQtDebugLogBrowser class
 *  简易的Qt消息浏览器
 *  目前只做到实时显示，显示历史消息未实现
 */
class ZFLIB_API ZQtDebugLogBrowser : public QMainWindow
{
    Q_OBJECT

public:
    explicit ZQtDebugLogBrowser(QWidget *parent = NULL);
    ~ZQtDebugLogBrowser();

    /**
     * @brief setMaximunLogCount
     *  设置最大日志数
     * @param log_count
     */
    void setMaximunLogCount(uint log_count);

    /**
     * @brief setShowDebugMsg
     *  设置是否显示调试信息
     * @param show
     */
    void setShowDebugMsg(bool show);

    /**
     * @brief clearDisplay
     *  清除所有显示
     */
    void clearDisplay();

public slots:
    void slotAppendMessage(const QtMsgType &, const QString &);

private:
    void init();
    void initUI();
    void createConnects();
    void translateLanguage();

private:
    QTextBrowser *m_browser;
    QToolBar *m_toolbar;
    QAction *m_action_clear;
    QAction *m_action_debug;
    QLabel *m_label_max_log;

    qint64 m_max_log_count;
    bool m_show_debug_msg;

private slots:
    void slotClearBrowser();
    void slotContextMenuRequested(const QPoint &pos);
    void slotSetShowDebugMessageEnable(bool show);
};

#endif // LDRS_LOG_BROWSER_H

